import { Resizable } from 'react-resizable';

function Resizecell({ onResize, width, ...restProps }) {
  
  if (!width) {
    return <th {...restProps} />;
  }


  return (
    <Resizable
      width={width ?? 100}
      height={0}
      onResize={onResize}
      draggableOpts={{ enableUserSelectHack: false }}
      handle={
        <span
          className="react-resizable-handle"
          onClick={(e) => {
            e.stopPropagation();
          }}
        />
      }
    >
      <th {...restProps} />
    </Resizable>
  );
}

export default Resizecell;
